package com.net.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import com.net.controller.model.ResponseModel;
import com.net.service.vo.ServiceCode;



public class ResponseEntityHelper {

	public static ResponseEntity<ResponseModel> createResponse(Integer code, String message, Object data) {
		ResponseModel res = new ResponseModel();
		res.setCode(code);
		res.setMessage(message);
		res.setData(data);
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}

	public static ResponseEntity<ResponseModel> createResponse(Integer code, String message) {
		ResponseModel res = new ResponseModel();
		res.setCode(code);
		res.setMessage(message);
		res.setData(null);
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}

	public static ResponseEntity<ResponseModel> createResponse(Object data) {
		ResponseModel res = new ResponseModel();
		res.setCode(ServiceCode.SUCCESS);
		res.setMessage("成功");
		res.setData(data);
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}

	/**
	 * 不需要封装参数 直接返回 ResponseModel
	 * @param res
	 * @return
	 */
	public static ResponseEntity<ResponseModel> returnResponse(ResponseModel res) {
		return new ResponseEntity<ResponseModel>(res, HttpStatus.OK);
	}

}
